package com.blog.controller;

import com.blog.domain.DTO.AddUserDto;
import com.blog.domain.DTO.UserDto;
import com.blog.domain.DTO.UserInfoDto;
import com.blog.domain.DTO.UserStatusDto;
import com.blog.domain.ResponseResult;
import com.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("system/user")
public class UserController {

	@Autowired
	private UserService userService;

	/**用户分页查询
	 *
	 * @param pageNum
	 * @param pageSize
	 * @param userDto
	 * @return
	 */
	@GetMapping("/list")
	public ResponseResult getUserList(Integer pageNum, Integer pageSize
	, UserDto userDto){

		return userService.getUserList(pageNum,pageSize,userDto);
	}


	/**新增用户
	 *
	 * @param addUserDto
	 * @return
	 */
	@PostMapping
	public ResponseResult addUser(@RequestBody AddUserDto addUserDto){
		return userService.addUser(addUserDto);

	}

	/**删除用户
	 *
	 * @param ids
	 * @return
	 */

	@DeleteMapping("/{id}")
	public ResponseResult deleteUser(@PathVariable("id") List<Long> ids){
		return  userService.deleteUser(ids);

	}

	/** 根据id查询用户信息回显
	 *
	 * @param id
	 * @return
	 */
	@GetMapping("/{id}")
	public ResponseResult getUserDetail(@PathVariable Long id){
		return userService.getUserDetail(id);

	}

	/**更改用户状态
	 *
	 * @param userStatusDto
	 * @return
	 */
	@PutMapping("/changeStatus")
	public ResponseResult changeStatus(@RequestBody UserStatusDto userStatusDto){
		return userService.changeStatus(userStatusDto);
	}

	/**更新用户信息
	 *
	 * @param userInfoDto
	 * @return
	 */
	@PutMapping
	public ResponseResult adminUpdateUserInfos(@RequestBody UserInfoDto userInfoDto){
		return userService.adminUpdateUserInfos(userInfoDto);


	}

}
